from autoTest_ecshop.utils.log_util import logger


def assert_util(expectRes,compare,actualRes):
    try:
        logger.info(f"断言:{expectRes} {compare} {actualRes}")
        if compare =="in":
            ##断言
            assert expectRes in actualRes
        elif compare == "==":
            assert expectRes == actualRes
        elif compare == ">":
            assert expectRes > actualRes
        elif compare == ">=":
            assert expectRes >= actualRes
        elif compare == "<":
            assert expectRes < actualRes
        elif compare == "<=":
            assert expectRes <= actualRes
        elif compare == "!=" or compare == "<>":
            assert expectRes !=actualRes
        else:
            logger.error("您输入的对比方式有误!")
            raise
        logger.info(f"断言成功.\n")
    except Exception as e:
        logger.info(f"断言失败，错误信息是：\n {e}\n")
        raise
